package zut.edu.cs.network.io.stream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamDemo {

	public static void main(String[] args) {
		File file = new File("test.txt");
		String string = "i am a test"+"\n welcome to my world";
		byte[] b = string.getBytes();
		try {
			FileOutputStream file1 = new FileOutputStream(file);
			file1.write(b);
			file1.close();
			System.out.println("写入成功！");
		} catch (FileNotFoundException e) {
			System.out.println("文件不存在");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("写入错误");
			e.printStackTrace();
		}

	}

}
